package com.fmdj.customer.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import com.fmdj.common.util.CommonResult;
import com.fmdj.customer.controller.form.ReceiveBillMessageForm;
import com.fmdj.customer.service.MessageService;
import com.fmdj.mps.controller.form.SearchOrderLocationCacheForm;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.HashMap;

@RestController
@RequestMapping("/message")
@Tag(name = "MessageController", description = "接收消息模块web接口")
@Slf4j
public class MessageController {

    @Autowired
    private MessageService messageService;

    @PostMapping("/receiveBillMessage")
    @Operation(summary = "接收账单消息")
    @SaCheckLogin
    public CommonResult receiveBillMessage(@Valid @RequestBody ReceiveBillMessageForm form) {
        long driverId = StpUtil.getLoginIdAsLong();
        form.setUserId(driverId);
        form.setIdentity("customer_bill");
        String msg = messageService.receiveBillMessage(form);
        return CommonResult.ok().put(CommonResult.RETURN_RESULT, msg);
    }
}
